<?php
include "include/config.inc.php";
error_reporting(0);

if(!isset($_SESSION['s_activId']))
{
  header('location:index.php');
}
if(isset($_POST['submitBtn']))
{
	$accountName = isset($_POST['accountName']) && $_POST['accountName'] != '' ? $_POST['accountName'] : 0;
	$openingDrCr = isset($_POST['openingDrCr']) && $_POST['openingDrCr'] != '' ? $_POST['openingDrCr'] : '';
	$opening     = isset($_POST['opening']) && $_POST['opening'] != '' ? $_POST['opening'] : 0;
	$isDayBook   = isset($_POST['isDayBook']) && $_POST['isDayBook'] == 'on' ? 1 : 0;
	
  $insertAccount = "INSERT INTO account (accountName,openingDrCr,opening,isDayBook)
                         VALUE ('".$accountName."','".$openingDrCr."',".$opening.",'".$isDayBook."')";
  $insertAccountRes = mysql_query($insertAccount);
}

$drCrValuesArr[0] = "Dr";
$drCrOutputArr[0] = "Debit";
$drCrValuesArr[1] = "Cr";
$drCrOutputArr[1] = "Credit";

include("bottom.php");
$smarty->assign('drCrValuesArr',$drCrValuesArr);
$smarty->assign('drCrOutputArr',$drCrOutputArr);
$smarty->display('account.tpl');  
?>